|
1
|
|
|
import csvjson from 'csvjson'; |
|
2
|
|
|
import CreateServer from '../CreateServer'; |
|
3
|
|
|
import ServersDropdown from '../ServersDropdown'; |
|
4
|
|
|
import DeleteServerModal from '../DeleteServerModal'; |
|
5
|
|
|
import DeleteServerButton from '../DeleteServerButton'; |
|
6
|
|
|
import ImportServersBtn from '../helpers/ImportServersBtn'; |
|
7
|
|
|
import { resetSelectedServer, selectServer } from '../reducers/selectedServer'; |
|
8
|
|
|
import { createServer, createServers, deleteServer, listServers } from '../reducers/server'; |
|
9
|
|
|
import ServersImporter from './ServersImporter'; |
|
10
|
|
|
import ServersService from './ServersService'; |
|
11
|
|
|
import ServersExporter from './ServersExporter'; |
|
12
|
|
|
|
|
13
|
|
|
const provideServices = (bottle, connect, withRouter) => { |
|
14
|
|
|
// Components |
|
15
|
|
|
bottle.serviceFactory('CreateServer', CreateServer, 'ImportServersBtn'); |
|
16
|
|
|
bottle.decorator('CreateServer', connect([ 'selectedServer' ], [ 'createServer', 'resetSelectedServer' ])); |
|
17
|
|
|
|
|
18
|
|
|
bottle.serviceFactory('ServersDropdown', ServersDropdown, 'ServersExporter'); |
|
19
|
|
|
bottle.decorator('ServersDropdown', connect([ 'servers', 'selectedServer' ], [ 'listServers', 'selectServer' ])); |
|
20
|
|
|
|
|
21
|
|
|
bottle.serviceFactory('DeleteServerModal', () => DeleteServerModal); |
|
22
|
|
|
bottle.decorator('DeleteServerModal', withRouter); |
|
23
|
|
|
bottle.decorator('DeleteServerModal', connect(null, [ 'deleteServer' ])); |
|
24
|
|
|
|
|
25
|
|
|
bottle.serviceFactory('DeleteServerButton', DeleteServerButton, 'DeleteServerModal'); |
|
26
|
|
|
|
|
27
|
|
|
bottle.serviceFactory('ImportServersBtn', ImportServersBtn, 'ServersImporter'); |
|
28
|
|
|
bottle.decorator('ImportServersBtn', connect(null, [ 'createServers' ])); |
|
29
|
|
|
|
|
30
|
|
|
// Services |
|
31
|
|
|
bottle.constant('csvjson', csvjson); |
|
32
|
|
|
bottle.constant('window', global.window); |
|
33
|
|
|
bottle.service('ServersImporter', ServersImporter, 'csvjson'); |
|
34
|
|
|
bottle.service('ServersService', ServersService, 'Storage'); |
|
35
|
|
|
bottle.service('ServersExporter', ServersExporter, 'ServersService', 'window', 'csvjson'); |
|
36
|
|
|
|
|
37
|
|
|
// Actions |
|
38
|
|
|
bottle.serviceFactory('selectServer', selectServer, 'ServersService'); |
|
39
|
|
|
bottle.serviceFactory('createServer', createServer, 'ServersService'); |
|
40
|
|
|
bottle.serviceFactory('createServers', createServers, 'ServersService'); |
|
41
|
|
|
bottle.serviceFactory('deleteServer', deleteServer, 'ServersService'); |
|
42
|
|
|
bottle.serviceFactory('listServers', listServers, 'ServersService'); |
|
43
|
|
|
|
|
44
|
|
|
bottle.serviceFactory('resetSelectedServer', () => resetSelectedServer); |
|
45
|
|
|
}; |
|
46
|
|
|
|
|
47
|
|
|
export default provideServices; |
|
48
|
|
|
|